package function;

import common.PostJson;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class HelpAction {

    private static String GetLocInfo_URL="http://106.15.43.138:8080/api/user/get_location_info";
    //城市是否开通帮邦行

    private static String GetNearbys_URL="http://api.bbxdomain.com/api/lead_stops/get_nearbys";
    //推荐上车点

    private static String OrderDetail_URL="http://api.bbxdomain.com/api/order/detail";
    //订单详情

    private static String OrderList_URL="http://106.15.43.138:8080/api/order/lists";
    //历史收件人

    private static String GetCouponInfo_URL="http://106.15.43.138:8080/api/coupon/getinfo";
    //优惠券信息

    private static String Evaluate_URL="http://106.15.43.138:8080/api/order/evaluate";
    //订单评价

    private static String GetBrief_URL="http://115.159.89.35:12306/order/get_brief";
    //获取概要（订单追踪）
    private static String GetDetail_URL="http://115.159.89.35:12306/order/get_detail";
    //获取详情（订单追踪）

    private static String GetStatusInfos_URL="http://106.15.43.138:8080/api/package/status_infos";
    //多笔订单状态查询
    private static String GetStatusInfo_URL="http://106.15.43.138:8080/api/package/status_info";
    //订单状态查询

    private static String PayStatus_URL="http://106.15.43.138:8080/bak/order/pay_status";
    //订单支付状态

    private static String VolumnList_URL="http://106.15.43.138:8080/bak/order/address_list";
    //包裹体积列表
    private static String WeightList_URL="http://106.15.43.138:8080/api/package/weight_lists";
    //包裹重量列表

    private static String Submit_URL="http://api.bbxdomain.com/api/order/submit";
    //提交寄件

    private static String CalPrice_URL="http://api.bbxdomain.com/bak/price/v";
    //价格计算

    private static String CreatOrder_URL="http://api.bbxdomain.com/api/pay/user_create_order_plus";
    //订单支付



    //订单是否评价*
    //添加收件人*

    //城市是否开通帮邦行
    public static String GetLocInfo(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,GetLocInfo_URL);
        JSONObject bjson = JSONObject.fromObject(ajson);
        JSONArray client = bjson.getJSONArray("client_menu");
        JSONObject jsonObject1 = new JSONObject();
        boolean flag =false;
        for(int i =0;i<client.size();i++){
            JSONObject cjson = client.getJSONObject(i);
            String id = cjson.getString("obj_id");
            if(id.equals("3")){
                jsonObject1.put("status",1);
                flag =true;
            }
        }
        if(flag==true){
            return jsonObject1.toString();
        }
        else{
            jsonObject1.put("status",0);
            return jsonObject1.toString();
        }
    }

    //历史收件人
    public static String OrderList(JSONObject jsonObject){
        String ajson = PostJson.postJson(jsonObject,OrderList_URL);
        JSONObject jsonObject1 = JSONObject.fromObject(ajson);
        JSONArray list = jsonObject1.getJSONArray("list");
        for(int i=0;i<list.size();i++){
            JSONObject bjson = list.getJSONObject(i);
            JSONObject end_info = bjson.getJSONObject("end");
            String name = end_info.getString("name");
            if(!(name.equals(""))) {
                String address = end_info.getString("address");
                String street = end_info.getString("street");
                String phone = end_info.getString("phone");
                JSONObject jsonObject2 =new JSONObject();
                jsonObject2.put("name",name);
                jsonObject2.put("phone",phone);
                jsonObject2.put("address",address);
                jsonObject2.put("street",street);
                jsonObject1.put(i,jsonObject2);
            }
        }
        return jsonObject1.toString();
    }


    //获取优惠券信息
    public static String GetCouponInfo(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,GetCouponInfo_URL);
        return ajson;
    }

    //订单评价
    public static String Evaluate(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,Evaluate_URL);
        return ajson;
    }

    //获取概要（订单追踪）
    public static String GetBrief(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,GetBrief_URL);
        return ajson;
    }
    //获取详情（订单追踪）
    public static String GetDetail(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,GetDetail_URL);
        return ajson;
    }

    //订单状态查询
    public static String GetStatusInfo(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,GetStatusInfo_URL);
        return ajson;
    }
    //多笔订单状态查询
    public static String GetStatusInfos(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,GetStatusInfos_URL);
        return ajson;
    }

    //订单支付状态
    public static String PayStatus(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,PayStatus_URL);
        return ajson;
    }

    //包裹体积列表
    public static String VolumnList(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,VolumnList_URL);
        return ajson;
    }

    //包裹重量列表
    public static String WeightList(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,WeightList_URL);
        return ajson;
    }

    //提交寄件
    public static String Submit(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,Submit_URL);
        return ajson;
    }

    //价格计算
    public static String CalPrice(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,CalPrice_URL);
        return ajson;
    }

    //订单支付
    public static String CreatOrderPay(JSONObject jsonObject){
        String ajson =PostJson.postJson(jsonObject,CreatOrder_URL);
        return ajson;
    }

    //推荐上车点
    public static String GetNearbys(JSONObject jsonObject){
        String ajson = PostJson.postJson(jsonObject,GetNearbys_URL);
        return ajson;
    }

    //订单详情
    public static String OrderDetail(JSONObject jsonObject){
        String ajson = PostJson.postJson(jsonObject,OrderDetail_URL);
        return ajson;
    }
}
